
<template>
  <!-- 导入 -->
  <div>
    <avue-radio
      :button="true"
      v-model="returnOrderType"
      :dic="dic"
      :disabled="true"
    ></avue-radio>

  <div style="margin-top:30px">
    <!-- form -->
    <avue-form
      :option="option"
      v-model="form"
      @submit="handleSubmit"
    >
      <template
        slot-scope="scope"
        slot="menuForm"
      >
        <el-button @click="handleCancel">取消</el-button>
      </template>
      <template
        slot-scope="{row}"
        slot="supShortAmount"
      >
        {{row.supShortAmount | rcaNumberFormat}}
      </template>
      <template
        slot-scope="{row}"
        slot="supUnloadAmount"
      >
        {{row.supUnloadAmount | rcaNumberFormat}}
      </template>
    </avue-form>

  </div>
  </div>
</template>

<script>
import { fetchList, getObj, confirm, putObj } from '@/api/rca/swckelectronicreceipt'
import { formOptionMap, orderType as orderTypeOptions } from '@/const/crud/rca/swckelectronicreceipt'

export default {
  name: "Edit",
  data () {
    return {
      form: {},
      dic: orderTypeOptions,
    };
  },
  props: ["dialogImportVisible", "target", "readonly"],
  computed: {
    returnOrderType () {
      return this.target.returnOrderType
    },
    option () {
      return formOptionMap[this.returnOrderType]
    }
  },
  created () {
    const {
      target
    } = this;
    this.form = {
      ...target,
      bankAccountBalance: target.bankAccountBalance/100,
      bankElecOrderAmount: target.bankElecOrderAmount/100,
      deductHandServiceMoney: target.deductHandServiceMoney/100,
      mailingCost: target.mailingCost/100,
      diffAccountAmount: target.diffAccountAmount/100,
      diffElecAmount: target.diffElecAmount/100,
      discountAmount: target.discountAmount/100,
      handServiceMoney: target.handServiceMoney/100,
      saleAmount: target.saleAmount/100,
    }
  },
  methods: {
    handleClose () {
      this.$emit("close");
    },
    handleCancel () {
      this.handleClose();
    },
    async handleSubmit (form) {
      const params = {
        ...this.form,
      bankAccountBalance: this.form.bankAccountBalance*100,
      bankElecOrderAmount: this.form.bankElecOrderAmount*100,
      deductHandServiceMoney: this.form.deductHandServiceMoney*100,
      mailingCost: this.form.mailingCost*100,
      diffAccountAmount: this.form.diffAccountAmount*100,
      diffElecAmount: this.form.diffElecAmount*100,
      discountAmount: this.form.discountAmount*100,
      handServiceMoney: this.form.handServiceMoney*100,
      saleAmount: this.form.saleAmount*100,
      }
      await putObj(params)
      this.$message.success("修改成功")
      this.handleClose()
    },
  },
};
</script>
<style lang="scss">
</style>
